import UIKit

class AlbumImageInfo: NSObject {
    // 颜色模式(RGB)
    lazy var colorModel: String = {
        if let dict = self.dict {
            return String(dict["ColorModel"]) ?? ""
        }
        return ""
    }()
    
    // 每英寸所打印的点数
    lazy var dPIWidth: CGFloat = {
        if let dict = self.dict {
            return (dict["DPIWidth"] as? CGFloat) ?? 0
        }
        return 0
    }()
    lazy var dPIHeight: CGFloat = {
        if let dict = self.dict {
            return (dict["DPIHeight"] as? CGFloat) ?? 0
        }
        return 0
    }()
    
    // 深度值
    lazy var depth: Int = {
        if let dict = self.dict {
            return ((dict["Depth"]) as? Int) ?? 0
        }
        return 0
        
    }()
    
    // 像素宽度
    lazy var pixelWidth: CGFloat = {
        if let dict = self.dict {
            return ((dict["PixelWidth"]) as? CGFloat) ?? 0
        }
        return 0
    }()
    
    // 像素高度
    lazy var pixelHeight: CGFloat = {
        if let dict = self.dict {
            return ((dict["PixelHeight"]) as? CGFloat) ?? 0
        }
        return 0
    }()
    
    // 配置文件名
    lazy var profileName: String = {
        if let dict = self.dict {
            return String(dict["ProfileName"])
        }
        return ""
    }()
    
    // 扩展信息
    lazy var EXIF: AlbumImageExif? = {
        if let dict = self.dict {
            let dictExif = dict["{Exif}"] as? NSDictionary
            return AlbumImageExif(dict: dictExif)
        }
        return nil
    }()
    // 标签图像文件格式
    lazy var TIFF: AlbumImageTIFF? = {
        if let dict = self.dict {
            let dictTIFF = dict["{TIFF}"] as? NSDictionary
            return AlbumImageTIFF(dict: dictTIFF)
        }
        return nil
    }()
    
    var dict: NSDictionary?
    init(dict: NSDictionary) {
        self.dict = dict
        
        super.init()
        // print("AlbumImageInfo:  colorModel: \(colorModel), dPIWidth: \(dPIWidth), dPIHeight: \(dPIHeight), depth: \(depth), pixelWidth: \(pixelWidth), pixelHeight: \(pixelHeight), profileName: \(profileName)")
    }
    
    deinit {
        // print("Album -- AlbumImageInfo: \(profileName) deinit")
    }
}
